package com.funny.controller;

import com.funny.entity.OrderProduction;
import com.funny.feign.PointOpenFeignService;
import com.funny.service.RedisService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Ming
 * @description
 * @fileSimpleName OrderTestController
 * @fileName com.funny.controller.OrderTestController
 * @date 2024年07月02日 18:40
 */
@Slf4j
@RestController
@RequestMapping(value = "/order")
public class OrderTestController {

    @Autowired
    private RedisService redisService;
    @Autowired
    private PointOpenFeignService pointOpenFeignService;

    @RequestMapping("/query-demo")
    public String queryDemo() {
        return "https://www.baidu.com/2323232";
    }

    @RequestMapping("query-color")
    public String queryUserInfo(@RequestParam("color") String color) {
        log.info("getaway获取请求参数{}", color);
        return "下单成功,getaway获取请求参数" + color;
    }

    @PostMapping("/addPoint")
    public String addPoint() {
        OrderProduction orderProduction = new OrderProduction();
        orderProduction.setProductionId("1");
        orderProduction.setProductionName("电脑");
        log.info("order 调用 point success ");
        return pointOpenFeignService.addPoint(orderProduction);
    }

    @PostMapping("/addPoint2")
    public String addPoint2(@RequestParam(value = "productionName", required = false) String productionName) {
        log.info("order 调用 addPoint2 success ");
        if (StringUtils.isBlank(productionName)) {
            productionName = "apple";
        }
        return pointOpenFeignService.addPoint2(productionName);
    }

}
